package org.liveboardgames.agricola.business;

import java.util.ArrayList;
import java.util.List;

import org.liveboardgames.agricola.access.ICardDao;
import org.liveboardgames.agricola.business.updater.CardUpdater;
import org.liveboardgames.agricola.controller.AgricolaUpdateAdapter;
import org.liveboardgames.agricola.domain.Change;
import org.liveboardgames.agricola.domain.card.Card;

public class CardServiceImpl implements ICardService {

  private ICardDao cardDao;

  public void setCardDao(ICardDao cardDao) {
    this.cardDao = cardDao;
  }

  public void emptyCard(Long gameId, Long cardId) {
    Card card = (Card)cardDao.load(cardId);

    List<Change> changes = new ArrayList<Change>();
    new CardUpdater(card, changes).resetResources();

    cardDao.save(card);

    new AgricolaUpdateAdapter().publishGameUpdates(gameId, changes);

  }

}
